package com.endurance.service.impl;

import com.endurance.compoent.TransactionManager;
import com.endurance.dao.ProductDao;
import com.endurance.pojo.Product;
import com.endurance.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 不实现任何接口，通过CGLIB技术来代理此类
 */
@Service
public class ProductServiceImpl3 {

    @Autowired
    private TransactionManager transactionManager;

    @Autowired
    private ProductDao productDao;

    public void updateProduct(Product product) {
        productDao.updateProduct(product);
        // 摸你在更新的过程中出现异常
        int i = 1 / 0;
    }

    public List<Product> findAll() {
        return productDao.findAll();
    }

    public void saveProduct(Product product) {
        productDao.saveProduct(product);
    }

    public void deleteProduct(Integer id) {
        productDao.deleteProduct(id);
    }

    public Product findById(Integer id) {
        return productDao.findById(id);
    }

}
